package com.ishowcode.config;

import com.ishowcode.beans.Car;
import com.ishowcode.beans.People;
import com.ishowcode.beans.Pet;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Import({People.class,Pet.class})
@Configuration(proxyBeanMethods = false)//代理对象调用方法，保持组件单实例
@EnableConfigurationProperties(Car.class)
public class MyConfig {
    @Bean("user01")
    public People user(){
        return new People("xt",23);
    }
    @ConditionalOnBean(name = "user01")
    @Bean("pet01")
    public Pet cat(){
        return new Pet("tom",10);
    }

}
